<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" language="java"%>
<%@ page buffer="50kb"%>
<%@taglib prefix="s" uri="/struts-tags" %>

<meta name="robots" content="noindex, nofollow" />
<link href="../sample.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="./webeditor/fckeditor.js"></script>

<ww:bean
	name="cn.myapps.core.deploy.application.action.ApplicationHelper"
	id="ApplicationHelper" />
<ww:bean
	name="cn.myapps.core.style.repository.action.StyleRepositoryHelper"
	id="sh">
	<ww:param name="applicationid" value="#parameters.application" />
	<ww:param name="moduleid" value="#parameters.s_module" />
</ww:bean>
<ww:bean id="fh"
	name="cn.myapps.core.dynaform.form.action.FormHelper" />
<html>
<o:MultiLanguage>
<head>
<title>{*[Form]*}{*[Info]*}</title>
<link rel="stylesheet" href='<ww:url value="/resource/css/main.css" />'	type="text/css">
<style type="text/css">
	.listContent {float: left;}
	#act_list table td{padding-left: 3px; border: 2px solid #FFFFFF;}
</style>
	<!-- import prototype-window js lib -->
	<script type="text/javascript" src='<ww:url value="/dwr/engine.js"/>'></script>
	<script type="text/javascript" src='<ww:url value="/dwr/util.js"/>'></script>
	<script type="text/javascript" src='<ww:url value="/dwr/interface/ActivityUtil.js"/>'></script>
	<script type="text/javascript" src='<ww:url value="/dwr/interface/FormHelper.js"/>'></script>
	<script type="text/javascript" src='<ww:url value="/dwr/interface/Sequence.js"/>'></script>
	
	<script type="text/javascript" src='<ww:url value="confirm/confirm.js" />'> </script>
	<script type="text/javascript" src='dynamicTable.js'></script>
	
	<script>
var sContentPath = '<ww:url value="/"/>';
var contextPath = '<%=request.getContextPath()%>';
</script>
	<title>Register result</title>
	<script>
var deleteBtn = '{*[Delete]*}';
var emptyOption = '{*[Select]*}';
var pk = '{*[PrimaryKey]*}';
var application = '<%=request.getParameter("application")%>';

var mode = 'tab1';

var wx = '480px';
var wy = '250px';
function ev_createMenu(){//生成菜单
	var formid = document.forms[0].elements['content.id'].value;
	if (formid == "") {
		alert("{*[Please_Save]*}");
  	}else{
		var formid = document.forms[0].elements['content.id'].value;
		var url = contextPath + "/core/dynaform/form/menu.jsp?formid=" + formid +"&application=" + application;
		//var rtn = showframe("{*[menu]*}", url);
		OBPM.dialog.show({
				opener:window.parent.parent,
				width: 600,
				height: 400,
				url: url,
				args: {},
				title: '{*[Create]*}{*[Menu]*}',
				close: function(rtn) {
					if(rtn != null && rtn != '')
						alert(rtn);
				}
		});
  	}
}

function ev_init(){
	var type = "<ww:property value='content.type'/>";
	if(type==65536){
		document.getElementById('div_Seprate').style.display="";
		document.getElementById('div_tab5').style.display="";
	}
	actProcess.initList();
	var id = "<ww:property value='content.id'/>";
	if (id){
	FormHelper.getAllFields(id,false, function(options) {
			addOptions("fieldName", options);
			initfields();
			ev_switchpage(mode);
			//reSize();
			initRows(); 
		});
	}
}



function addOptions2(relatedFieldId, options, defValues){
	var el = document.getElementById(relatedFieldId);
	if(relatedFieldId){
		DWRUtil.removeAllOptions(relatedFieldId);
		DWRUtil.addOptions(relatedFieldId, options);
		if (defValues) {
			DWRUtil.setValue(relatedFieldId, defValues);
		}
		if (el.onchange && typeof(el.onchange) == "function") {
			el.onchange();
		}
	}
}


	// 增加element options
function addOptions(elemName, options) {
		var elems = document.getElementsByName(elemName);
		for (var i=0; i<elems.length; i++) {
			var defVal = elems[i].value;
			DWRUtil.removeAllOptions(elems[i].id);
			DWRUtil.addOptions(elems[i].id, options);
			DWRUtil.setValue(elems[i].id, defVal);
		}
	}

function addFieldOptions(relatedFieldId, defValues) {

	FormHelper.getFields(document.getElementById("content.id").value, function(options){
		var oFieldSelect = document.getElementById(relatedFieldId);
		var oSelectedList = document.getElementById("selectedList");
		DWRUtil.removeAllOptions(oSelectedList.id);
		addOptions2(relatedFieldId, options, defValues);
		moveSelectedOptions(oFieldSelect, oSelectedList, false, '');
	});
}

function moveup(){   
	var s =   document.all.fields;   
  	var v =   new   Array();   
    for(var i=0;i<s.length-1;i++){   
        if(!   s.options[i].selected   &&   s.options[i+1].selected){   
            v.value   =   s.options[i].value;   
            v.text   =   s.options[i].text;   
            v.selected   =   s.options[i].selected;   
            s.options[i].value   =   s.options[i+1].value;   
            s.options[i].text   =   s.options[i+1].text;   
            s.options[i].selected   =   s.options[i+1].selected;   
            s.options[i+1].value   =   v.value;   
            s.options[i+1].text   =   v.text;   
            s.options[i+1].selected   =   v.selected;   
        }   
    }   
} 

function movedown(){   
    var s = document.all.fields;
    var v = new Array();   
    for(var i = s.length-1; i > 0; i--){   
        if(!s.options[i].selected && s.options[i-1].selected){   
            v.value = s.options[i].value;   
            v.text = s.options[i].text;   
            v.selected = s.options[i].selected;   
            s.options[i].value = s.options[i-1].value;   
            s.options[i].text = s.options[i-1].text;   
            s.options[i].selected = s.options[i-1].selected;   
            s.options[i-1].value = v.value;   
            s.options[i-1].text = v.text;   
            s.options[i-1].selected = v.selected;   
        }   
    }   
}  
    
function addItem(source,target){ 
	for(var i=0;i<source.length;i++){	 
		if(source.options(i).selected==true){
			var Opt=document.createElement("option");
			Opt.value=source.options(i).value;
			Opt.text=source.options(i).text;
			var k=0;
			for(var j=0;j<target.length;j++){
			    if(source.options(i).value==target.options(j).value){
				   k=1;
				}
			}
			if(k==0){
			    target.options.add(Opt);
			    //source.options[i]="";
			}
		}	
	}
} 

function delItem(source,target){ 
	for(var x = target.length-1;x >= 0;x--){ 
		var opt = target.options[x]; 
		if (opt.selected){
			var fieldname=document.all.fieldName;
			var flag = true;
			for(var i=fieldname.length-1;i>=0;i--){
				if (fieldname.options[i].value==opt.value){
					flag=false;
					break;
				}
			}
			if (flag){
			var Opt=document.createElement("option");
			Opt.value=opt.value;
			Opt.text=opt.text;
		 	fieldname.options.add(Opt);
			}
		 	target.options[x] = null;
		} 
	}
} 

function RelStr(str){
	var test = "";
		if (str!=null && str.length>2){
			str = str.substring(1,str.length-1);
			var cols = str.split(",");
			if (cols.length>0){
				var str1 = '[';
				for (var i=0;i<cols.length;i++) {
					var col = cols[i].split(":");
					str1 += '{';
					str1 += 'fieldOrder:\''+col[0]+'\',';
					str1 += 'fieldname:'+col[1];
					str1 += '},';
				}
				if (str.lastIndexOf(',') != -1) {
					str1 = str1.substring(0, str1.length - 1);
				}
				test = str1 + ']';
			}
		}
		var obj = eval(test);
		if (obj instanceof Array) {
			return obj;
		} else {
			return new Array();	
		}
}

function createJSONStr() {
	var fields=  document.all.fields;
	if (fields){
	var str = '{';
		for (var i=0;i<fields.length;i++) {
			if (fields.options(i).value != '') {
				str += (i+1) +':\''+fields.options(i).value;
				str += '\',';
			}
		}
		if (str.lastIndexOf(',') != -1) {
			str = str.substring(0, str.length - 1);
		}
		str += '}';
	
	return str;
	}
	return "";
}

function initfields(){
	var str = document.getElementsByName('content.relationText')[0].value;
	if(str.length>0){
		var obj=RelStr(str);
		if(obj!=null){
			if(obj.length>0){
				var field=document.all.fields;
				var fieldname=document.all.fieldName;	
				for(var i=0;i<obj.length;i++){
					for(var j=0;j<fieldname.length;j++){
					if (obj[i]){
					if (fieldname.options[j].value==obj[i].fieldname)
					{
						var Opt=document.createElement("option");
						Opt.value=obj[i].fieldname;
						Opt.text=fieldname.options[j].text;
						field.options.add(Opt);
						//fieldname.options[j]="";
						break;
					}
					}
		     	}
	       	}
   		}
	}
}
}

function checkDimension() {
	var sWidth = document.body.clientWidth;
	var sHeight = document.body.clientHeight;
}

function fadein(obj) {
	obj.style.backgroundColor = "#E9E9E9";
}

function fadeout(obj) {
	obj.style.backgroundColor = "#FFF";	
}

window.onload=function(){
	ev_init();
	window.top.toThisHelpPage("application_module_form_info");
	
	var fieldDefValues = getSelectedValuesByFiled(document.getElementById("content.summaryCfg.fieldNames"));

	addFieldOptions("fieldSelect", fieldDefValues);
	
	modeChange('<ww:property value="content.summaryCfg.type" />');
	document.getElementById("selectedList").style.width=120;

	resplaceImg('<ww:property value="content.summaryCfg.style" />');
	
}

function getSelectedValuesByFiled(oField, separator) {
	if (!oField) return;
	 oField.value.replace("")
	separator = separator ? separator : ";";
	var valueList = oField.value.split(separator);
	return valueList;
}

function ev_switchpage(sId) {
	
	document.getElementById('span_tab1').className="btcaption";
	document.getElementById('span_tab2').className="btcaption";
	if (document.getElementById('span_tab3'))
		document.getElementById('span_tab3').className="btcaption";
	if (document.getElementById('span_tab4'))
		document.getElementById('span_tab4').className="btcaption";
	if (document.getElementById('span_tab5'))
		document.getElementById('span_tab5').className="btcaption";	
	if (document.getElementById('span_tab6'))
		document.getElementById('span_tab6').className="btcaption";	

	document.getElementById('tab1').style.display="none";
	document.getElementById('tab2').style.display="none";
	document.getElementById('tab3').style.display="none";
	document.getElementById('tab4').style.display="none";
	document.getElementById('tab5').style.display="none";
	document.getElementById('tab6').style.display="none";
	
	if (document.getElementById(sId)) {
		document.getElementById('span_'+sId).className="btcaption-s-selected";
		document.getElementById(sId).style.display="";
		window.top.toThisHelpPage(jQuery("#"+sId).attr("helpid"));
	}
		
	if (sId == 'tab3' || sId == 'tab4' || sId == 'tab5' || sId == 'tab6') {
		$("form_editor").style.display = "none";
		if (sId == 'tab5') {
			addFldOptions(); // dynamicTable.js
		}
	}
	else {
		$("form_editor").style.display = "";	
	}
	
	mode = sId;
}

function ev_preview(){
	var formid = document.forms[0].elements['content.id'].value;
	if (formid == "") {
		alert("{*[Please_Save]*}");
  	}
 	else {
 	 	
    	var url = '<ww:url action="preview" namespace="/core/dynaform/document" />' + '?_formid=' + formid + '&application=<%=request.getParameter("application")%>';
    	OBPM.dialog.show({
				opener:window.parent.parent,
				width: 800,
				height: 500,
				url: url,
				args: {},
				title: '{*[Preview]*}',
				close: function(rtn) {
				}
		});
 	}
}

function ev_onekeycreview(){
	var formid = document.forms[0].elements['content.id'].value;
	if(formid== ""){
		alert("{*[Please_Save]*}");
	}else{
		var url = '<ww:url action="onekeycreview" namespace="/core/dynaform/form" />' + '?_formid=' + formid+ '&application=<%=request.getParameter("application")%>&s_module=<%=request.getParameter("s_module")%>';
		window.location=url;
	}
}

function ev_cleardata(){
	var formid = document.forms[0].elements['content.id'].value;
	if(formid== ""){
		alert("{*[Please_Save]*}");
	}else{
	var url = '<ww:url action="beforecleardata" namespace="/core/dynaform/form" />' + '?id=' + formid+ '&applicationid=<%=request.getParameter("application")%>&s_module=<%=request.getParameter("s_module")%>';
    var viewurl="<ww:url action='edit'><ww:param name='_currpage' value='datas.pageNo' /><ww:param name='_pagelines' value='datas.linesPerPage' /><ww:param name='_rowcount' value='datas.rowCount' /><ww:param name='application' value='#parameters.application'/><ww:param name='s_module' value='#parameters.s_module'/></ww:url>";
	showframe("deletedata",url, false);
	  /*if (confirm("{*[confirm.clear.data]*}")) {
		  var url = '<ww:url action="cleardata" namespace="/core/dynaform/form" />';
		  document.forms[0].action= url;
		  document.forms[0].submit();
	  }*/
	}
}

function ExecuteCommand( commandName )
{
	// Get the editor instance that we want to interact with.
	var oEditor = FCKeditorAPI.GetInstance('content.templatecontext') ;

	// Execute the command.
	oEditor.Commands.GetCommand( commandName ).Execute() ;
}


// 重设重复的字段ID
function resetDuplicateField() {
	var oEditor = FCKeditorAPI.GetInstance("content.templatecontext");
	
	if (oEditor.EditorDocument == null) {
		return;
	}
	
	var els = oEditor.EditorDocument.body.all;
	
	var ids = [];
	if (els && els.length > 0){
		DWREngine.setAsync(false);
		for (var i=0; i<els.length; i++) {
			var tagName = els[i].tagName.toUpperCase();
			if ((tagName == 'INPUT' || tagName == 'TEXTAREA' || tagName == 'SELECT' || tagName == 'IMG') 
				&& ids.indexOf(els[i].id) != -1) { //prototype.js
				// reset ID
				Sequence.getSequence(function(id) {
					els[i].id = id
				});
			}
			ids.push(els[i].id);
		}
		DWREngine.setAsync(true);
	}
}

// 重设所有表单字段ID
function resetAllFieldId(){
	if (confirm("{*[confirm.reset.all.field.id]*}")) {
		var oEditor = FCKeditorAPI.GetInstance("content.templatecontext");
	
		if (oEditor.EditorDocument == null) {
			return;
		}
		
		var els = oEditor.EditorDocument.body.all;
		
		if (els && els.length > 0){
			DWREngine.setAsync(false);
			for (var i=0; i<els.length; i++) {
				var tagName = els[i].tagName.toUpperCase();
				if (tagName == 'INPUT' || tagName == 'TEXTAREA' || tagName == 'SELECT' || tagName == 'IMG') {
					// reset ID
					Sequence.getSequence(function(id) {
						els[i].id = id
					});
				}
			}
			DWREngine.setAsync(true);
		}
	}
}

function ev_save() {
	DWREngine.setAsync(false);
	// 1. parse activity array to xml and set value to textarea
	ActivityUtil.parseObject(activityCache, function(xml){
		DWRUtil.setValue('activityXML', xml);
	});
	
	// 2. update all field's id
	resetDuplicateField();
	
	// 3.parse SMFieldNames to string and set value to content.relationText
	document.getElementById("relationTextId").value = createJSONStr();
	setMappingStr(); // dynamicTable.js

	//4.parse document summary config 
	 var oSel = document.getElementById("selectedList");
	 var oField = document.getElementById("content.summaryCfg.fieldNames");
	 setSelectedValuesToField(oField, oSel);
	
	// 5. check some changes of form.
	document.forms[0].action='<ww:url action="save"></ww:url>';
	document.forms[0].submit();

	
	
}

// sort by element order number
function sortByOrder(obj, anObj){
	return obj.orderno - anObj.orderno;
}
	
// swap element order number
function swap(obj, anObj){
	var tempOrderno = obj.orderno;
	obj.orderno = anObj.orderno;
	anObj.orderno = tempOrderno;
}


function changeMenu(s){
	if(s==65536){
		document.getElementById('div_Seprate').style.display="inline";
		document.getElementById('div_tab5').style.display="inline";
	}else{
		document.getElementById('div_Seprate').style.display="none";
		document.getElementById('div_tab5').style.display="none";
	}
}

function synchronouslyData(){
	    var formid = document.forms[0].elements['content.id'].value;
	    var tableName = document.getElementById("tableName").value;
	    var domainName = document.getElementById("domainName").value;
        if (formid == "" ) {
		    alert("{*[Please_Save]*}");
		    return ;
	    }else if(tableName == null || tableName ==""){
		    alert("{*[please.select]*}{*[Database]*}{*[Table]*}");
		    return ;
	    }else{
	    	if(PKchanged()){
			    var url = contextPath + '/core/dynaform/form/selectDomain.jsp?application='+application;
			    var value= window.showModalDialog(contextPath + '/frame.jsp?title={*[synchronouslyData]*}',
					    url, 'font-size:9pt;dialogWidth:' + 300 + 'px;dialogHeight:'
					    + 150 + 'px;status:no;scroll=no;');
			    document.getElementById("domainName").value=value;
			    if(value == "" || value == null || value == 'undefined'||document.getElementById("domainName").value==""){
				    alert("{*[please.select]*}{*[Domain]*}");
				    return ;
			    }else if(value =='canel'){
				    return ;
			    }else{
	 		    document.forms[0].action='<ww:url action="synchronouslyData"></ww:url>';
	 		    document.forms[0].submit();
			    }
	    	}
 	    }
}

function dupFieldValidation(obj){
	var mark = obj.id.substr(5)-1;
    var fields = document.getElementsByName("mFieldName");
    for(i = 0; i<fields.length; i++){
        temp= fields[i].value;
        if(temp!="" && mark!=i && temp==obj.value){
            alert("该字段已被占用!");
            obj.value=obj.value;
            break;
        }
    }
}

function PKchanged(){
	var Oldmid = document.getElementById("mappingID").value;
    var field = document.getElementsByName("mFieldName");
    var column = document.getElementsByName("mColumnName");
    var mark = -1;
	for(i=0;i<field.length;i++){
		if(field[i].value=="MAPPINGID"){
			mark = i;
		}
    }
    if(-1!=mark){
        var Newmid = column[mark].value;
        if(Newmid!=""){
            if(Oldmid!=Newmid){
             	alert("主键对应列已修改, 请保存表单后再进行同步数据操作。");
             	 return false;
            }
        }else{
            alert("请选择映射主键!");
            return false;
        }
    }else{
        alert("请选择映射主键!");
        return false;
    }
    return true;
}

function selectAllAct(b, isRefresh) {
	var c = document.all('activitySelects');
	if (c == null)
		return;

	if (c.length != null) {
		for (var i = 0; i < c.length; ++i)
			c[i].checked = b && !(c[i].disabled);
	} else {
		c.checked = b;
	}
}

function setSelectedValuesToField(oField, oSel, separator){
	if (!oField || oSel.options.length == 0){
		oField.value ="";
		 return;
	}
	separator = separator ? separator : ";";
	oField.value = '';
	for (var i=0; i<oSel.options.length; i++) {
		var option = oSel.options[i];
		oField.value += option.value + separator;
		
	}
	oField.value = oField.value.substring(0, oField.value.length-1);
}

function modeChange(value){
	if(value=='00'){
		document.getElementById("docSummaryCfg_type_00").style.display='';
		document.getElementById("docSummaryCfg_type_01").style.display='none';
	}
	if(value=='01'){
		document.getElementById("docSummaryCfg_type_01").style.display='';
		document.getElementById("docSummaryCfg_type_00").style.display='none';
	}
}
function resplaceImg(value){
	   var images = document.getElementById("image1");
	   if(value==1){
	   		images.src = '<ww:url value="/resource/imgnew/pending_img5.gif"/>';
	   }
	   if(value==2){
	   		images.src = '<ww:url value="/resource/imgnew/pending_img1.gif"/>';
	   }
	   if(value==3){
	   		images.src = '<ww:url value="/resource/imgnew/pending_img2.gif"/>';
	   }
	   if(value==4){
	   		images.src = '<ww:url value="/resource/imgnew/pending_img3.gif"/>';
	   }
	   if(value==5){
	   		images.src = '<ww:url value="/resource/imgnew/pending_img4.gif"/>';
	   }
	}
</script>
</head>
</o:MultiLanguage>
<body id="application_module_form_info" class="contentBody">
<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td height="27px;" valign="top" align="left">
		<o:MultiLanguage>
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td align="left">
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td class="nav-s-td">
							<table border="0" cellspacing="0" cellpadding="0" width="100%">
								<tr>
									<td style="padding-left: 10px;">
									<div id="sec_tab1">
									<div class="listContent"><input type="button"
										id="span_tab1" name="spantab1" class="btcaption"
										onClick="ev_switchpage('tab1')" value="{*[Basic]*}" /></div>
									<div class="listContent nav-seperate"><img
										src="<ww:url value='/resource/imgv2/back/main/nav_seperate2.gif' />" />
									</div>
									<div class="listContent"><input type="button"
										id="span_tab2" name="spantab2" class="btcaption"
										onclick="ev_switchpage('tab2')" value="{*[Format]*}" /></div>
									<ww:if test="content.id!=null && content.id!=''">
										<div class="listContent nav-seperate"><img
											src="<ww:url value='/resource/imgv2/back/main/nav_seperate2.gif' />" />
										</div>
										<div class="listContent"><input type="button"
											id="span_tab3" name="spantab3" class="btcaption"
											onClick="ev_switchpage('tab3')" value="{*[Activity]*}" /></div>
										<div class="listContent nav-seperate"><img
											src="<ww:url value='/resource/imgv2/back/main/nav_seperate2.gif' />" />
										</div>
										<div class="listContent"><input type="button"
											id="span_tab6" name="spantab6" class="btcaption"
											onClick="ev_switchpage('tab6')" value="{*[core.workflow.storage.runtime.intervention.summary]*}" />
										</div>
									</ww:if></div>
									<!-- 分隔线 -->
										<div class="listContent nav-seperate" id="div_Seprate" style='display:none;'><img
											src="<ww:url value='/resource/imgv2/back/main/nav_seperate2.gif' />" />
										</div>
										<div class="listContent" id="div_tab5" style='display:none;'><input type="button"
											id="span_tab5" name="spantab5" class="btcaption"
											onClick="ev_switchpage('tab5')" value="{*[Mapping]*}" /></div>
									</td>
								</tr>
							</table>
							</td>
						</tr>
					</table>
					</td>
					<td class="nav-s-td" align="right">
					<table border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td align="left">
							<button class="button-image" style="width:50px" onClick="ev_preview()"><img
								src="<ww:url value="/resource/imgnew/act/preview.gif" />"
								align="top">{*[Preview]*}</button>
							</td>
							<td align="left">
								<button class="button-image" style="width:75px" onClick="ev_createMenu()">
									<img src='<ww:url value="/resource/imgnew/act/act_2.gif" />'/>{*[Create]*}{*[Menu]*}
								</button>
							</td>
							<td align="left">
							<button class="button-image" style="width:105px" onClick="resetAllFieldId()">
								<img src="<ww:url value="/resource/imgnew/act/reset.gif" />"
								align="top">{*[Reset]*}{*[Field]*}{*[ID]*}</button>
							</td>
							<td align="left">
							<button class="button-image" style="width:80px" onClick="ev_cleardata()"><img
								src="<ww:url value="/resource/imgnew/act/act_3.gif" />"
								align="top">{*[Clear]*}{*[Data]*}</button>
							</td>
						    <td align="left">
							<button class="button-image" style="width:100px" onClick="ev_onekeycreview()"><img
								src="<ww:url value="/resource/imgnew/act/act_7.gif" />"
								align="top">{*[OneKey_Creview]*}</button>
							</td>
							<td align="left">
							<button id="save_btn" style="width:50px" class="button-image" onClick="ev_save()">
							<img src="<ww:url value="/resource/imgnew/act/act_4.gif"/>"
								align="top">{*[Save]*}</button>
							</td>
							<td align="left">
							<button class="button-image" style="width:50px"
								onClick="forms[0].action='<ww:url action="list"></ww:url>';forms[0].submit();">
							<img align="top"
								src="<ww:url value="/resource/imgnew/act/act_10.gif"/>">{*[Exit]*}</button>
							</td>
						</tr>
					</table>
		
					</td>
				</tr>
			</table>
		</o:MultiLanguage>
	</td></tr>
	<tr><td valign="top" align="left">
		<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
			<tr><td>
			<o:MultiLanguage>
			<%@include file="/common/msg.jsp"%>
			</o:MultiLanguage>
			<table  width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
				<ww:form id="formItem" action="save" method="post" theme="simple">
					<o:MultiLanguage>
					<%@include file="/common/page.jsp"%>
					<ww:hidden name='content.version' />
					<ww:hidden name="content.titlescript" />
		
					<input type="hidden" name="s_module"
						value="<ww:property value='#parameters.s_module'/>">
					<input type="hidden" name="moduleid"
						value="<ww:property value='#parameters.s_module'/>">
		
					<ww:textarea id="activityXML" name="content.activityXML"
						cssStyle="display:none" />
		
					<tr id="tab1" helpid="application_module_form_info" valign='top'>
						<td style="padding-left: 10px;padding-top: 10px;">
						<table border="0" cellpadding="0" cellspacing="0" width="100%" class="id1">
							<tr class="seperate">
								<td class="commFont">{*[Name]*}:</td>
								<td class="commFont">{*[Type]*}:</td>
							</tr>
							<tr>
								<td align="left"><ww:textfield id="name" cssClass="input-cmd"
									name="content.name" theme="simple" /></td>
								<td align="left"><ww:select name="content.type" onchange="changeMenu(this.value)"
									cssClass="input-cmd" list="_FORMTYPE" theme="simple" /></td>
							</tr>
							<tr class="seperate">
								<td class="commFont">{*[StyleLib]*}:</td>
								<td class="commFont">{*[ShowLog]*}:</td>
							</tr>
							<tr>
								<td><ww:select cssClass="select-size input-cmd"
									label="{*[StyleLib]*}" name="_styleid"
									list="#sh.get_listStyleByApp(#parameters.application)"
									listKey="id" listValue="name" emptyOption="true" theme="simple" /></td>
								<td><!--<ww:checkbox name="_isDisplayLog" theme="simple" />-->
								<ww:radio name="_isDisplayLog" theme="simple"
									list="#{'true':'{*[Yes]*}','false':'{*[No]*}'}"></ww:radio></td>
							</tr>
							<!-- <tr>
							   	<td class="commFont commLabel">{*[Leave]*}{*[Tips]*}:</td> 
							    <td><ww:checkbox name="_Tips" theme="simple"/></td>
							</tr> -->
							<tr class="seperate">
								<td class="commFont">{*[Description]*}:</td>
								<td class="commFont">{*[BeforopenScript]*}:   <button class="button-image" onclick="openIscriptEditor('content.beforopenscript','{*[Script]*}{*[Editor]*}','{*[BeforopenScript]*}','content.name','{*[Save]*}{*[Success]*}');"><img alt="Open with IscriptEditor" src="<ww:url value='/resource/image/editor.png' />"/></button></td>
							</tr>
							<tr id='beforeScriptContent'>
								<td align="left"><ww:textarea rows="4" cssClass="input-cmd"
									name="content.discription" theme="simple" /></td>
								<td><ww:textarea theme="simple" cssClass="input-cmd"
									name="content.beforopenscript" rows="4"></ww:textarea>
									</td>
							</tr>
					<!-- 原来放文档摘要配置的地方 -->
					
						</table>
						
						</td>
					</tr>
					</o:MultiLanguage>
					
					<tr id='tab2' helpid="application_module_form_info_advance" style='display: none' valign="top" height="100%">
						<td>
						<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%" align="center">
							<tr valign="top">
								<td height="100%">
								<div id="form_editor" height="100%"; style="overflow: hidden">
								<div id="eWebEditor" name="eWebEditor" >
								<ww:textarea cssStyle="display:none" name="content.templatecontext"
									theme="simple" />	 
								<script type="text/javascript">
									var sBasePath = '<ww:url value="/core/dynaform/form/webeditor/"/>';
									var oFCKeditor = new FCKeditor("content.templatecontext");
									//oFCKeditor.ToolbarSet = "myeditor";
									oFCKeditor.BasePath	= sBasePath;
									oFCKeditor.Height	= "100%";
									oFCKeditor.ReplaceTextarea();
								</script>
								</div>
								</div>
								</td>
							</tr>
						</table>
						</td>
					</tr>
					<tr id="tab3" helpid="application_module_form_info_activity" style="display: none; vertical-align: top;">
						<td width="100%">
						<script type="text/javascript">
						function ActivityProcess() {
						}
						ActivityProcess.prototype.initList = function(){
							var activityXML = DWRUtil.getValue("activityXML");
							if (activityXML) {
								var process = this;
								ActivityUtil.parseXML(activityXML, function(activitys){
									activityCache = activitys;
									process.refreshList(activityCache);
								});
							}
						}
						ActivityProcess.prototype.refreshList = function(activitys) {
							activitys.sort(sortByOrder);
							ActivityUtil.toListHtml(activitys, function(data){
								var act_list = $("act_list");
								act_list.innerHTML = data;
							});
						}
						ActivityProcess.prototype.doCreate = function(){
							var s_moduleid='<%=request.getParameter("s_module")%>';
							var applicationid='<%=request.getParameter("application")%>';
							var formid='<ww:property value='content.id'/>';
							var url= '<ww:url value="/core/dynaform/activity/content.jsp" />?application='+applicationid+'&_formid='+formid+'&s_module='+s_moduleid;
							OBPM.dialog.show({
									opener:window.parent.parent,
									width: 600,
									height: 500,
									url: url,
									args: {"parentObj":window,"application":applicationid,"_formid":formid,"s_module":s_moduleid},
									title: '{*[New]*}{*[Activity]*}{*[ButtonField]*}',
									close: function(result) {
										window.top.toThisHelpPage("application_module_form_info_activity");
									}
								});
							
							//$("act_content").innerHTML = frame;
						  	this.refreshList(activityCache);
						}
						ActivityProcess.prototype.doEdit = function(index) {
							var s_moduleid='<%=request.getParameter("s_module")%>';
							var applicationid='<%=request.getParameter("application")%>';
							var formid='<ww:property value='content.id'/>';
							var url= '<ww:url value="/core/dynaform/activity/content.jsp" />?application='+applicationid+'&_formid='+formid+'&s_module='+s_moduleid+'&index=' + index;
							OBPM.dialog.show({
									opener:window.parent.parent,
									width: 600,
									height: 500,
									url: url,
									args: {"parentObj":window,"application":applicationid,"_formid":formid,"s_module":s_moduleid},
									title: '{*[Edit]*}{*[Activity]*}{*[ButtonField]*}',
									close: function(result) {
										window.top.toThisHelpPage("application_module_form_info_activity");
									}
								});
							this.refreshList(activityCache);
						}
						ActivityProcess.prototype.doDelete = function() {
							var activitySelects = document.getElementsByName("activitySelects");
							for (var n=0; n<activitySelects.length; n++) {
								if (activitySelects[n].checked) {
									var index = activitySelects[n].value;
									activityCache[index] = null;
								}
							}
							activityCache = activityCache.compact();
							this.refreshList(activityCache);
						}
						
						ActivityProcess.prototype.doOrderChange = function(index, type) {
							switch(type){
								case 'p' :
								if (index != 0) {
									var activity = activityCache[index];
									var previousActivity = activityCache[index-1];
									swap(activity, previousActivity);
									this.refreshList(activityCache);
								}
								break;
								case 'n' :
								if (index != activityCache.length - 1) {
									var activity = activityCache[index];
									var nextActivity = activityCache[index+1];
									swap(activity, nextActivity);
									this.refreshList(activityCache);
								}
								break;
							}
						}
						var activityCache = [];
						var actProcess = new ActivityProcess();
						</script>
						<table width="100%" class="table_noboder">
							<tr><td>
								<button class="button-class" onClick="actProcess.doCreate()"
											title="{*[Create]*}"><img border="0"
											SRC="<ww:url value='/resource/imgnew/act/act_2.gif'></ww:url>"
											alt="{*[Create]*} {*[Activity]*}">{*[Create]*}</button>
								<button class="button-class" onClick="actProcess.doDelete()"
											title="{*[Delete]*}"><img border="0"
											SRC="<ww:url value='/resource/imgnew/act/act_3.gif'></ww:url>"
											alt="{*[Remove]*} {*[Activity]*}">{*[Delete]*}</button>
							</td></tr>
							<tr>
							<td style="width: 100%; vertical-align: top;text-align: left;">
								<div id="act_list" style="border: 0px solid;">&nbsp;</div>
							</td>
							</tr>
						</table>
						</td>
					</tr>
					<tr id='tab4' style='display: none' valign="top">
						<td colspan="4" height="20">
						<table width="100%">
							<tr>
								<td>
								<fieldset style="HEIGHT: 50px"><legend>{*[Basic]*}</legend>
								<table class="id1" width="80%">
									<tr>
										<td class="commFont">{*[Relation]*}{*[Name]*}:</td>
										<td class="commFont">{*[OnSaveStartFlow]*}:</td>
									</tr>
									<tr>
										<td><ww:textfield cssClass="input-cmd"
											name="content.relationName" theme="simple" /></td>
										<td><ww:radio name="_isOnSaveStartFlow" theme="simple"
											list="#{'false':'{*[No]*}','true':'{*[Yes]*}'}"></ww:radio></td>
									</tr>
								</table>
								</fieldset>
								</td>
							</tr>
							<tr>
								<td>
								<fieldset style="HEIGHT: 300px"><legend>{*[Configurations]*}</legend>
								<table style="width: 80%;" border="1">
									<tbody id="tb">
										<tr>
											<td colspan="2" align="center">
											<table>
												<tr>
													<td class="commFont">{*[FormField]*}</td>
													<td></td>
													<td class="commFont">{*[SelectField]*}</td>
												</tr>
												<tr>
													<td height="60" class="tdLabel"><select id="fieldName"
														name="fieldName" size="15" multiple="multiple"
														style="width: 10em"
														ondblclick="addItem(document.all.fieldName,document.all.fields)">
													</select></td>
													<td bgcolor="#FFFFFF">
													<p align="center">
													<button class="button-image" onClick="moveup()"><img
														src="<ww:url value="/resource/image/up2.gif"/>"
														alt="{*[Move_Up]*}"></button>
													</p>
													<p align="center">
													<button class="button-image"
														onClick="addItem(document.all.fieldName,document.all.fields)"><img
														src="<ww:url value="/resource/image/right2.gif"/>"
														alt="{*[Add]*}{*[Item]*}"></button>
													</p>
													<p align="center">
													<button class="button-image"
														onClick="delItem(document.all.fieldName,document.all.fields)"><img
														src="<ww:url value="/resource/image/left2.gif"/>"
														alt="{*[Delete]*}{*[Item]*}"></button>
													</p>
													<p align="center">
		
													<button class="button-image" onClick="movedown()"><img
														src="<ww:url value="/resource/image/down2.gif"/>"
														alt="{*[Move_Down]*}"></button>
													</p>
													</td>
													<td height="60" class="tdLabel">
													<div align="center"><select id="selectid" name="fields"
														size="15" multiple style="width: 10em"
														ondblClick="delItem(document.all.fieldName,document.all.fields)">
													</select></div>
													</td>
												</tr>
											</table>
											</td>
										</tr>
									</tbody>
								</table>
								</fieldset>
								<ww:textarea id="relationTextId" cssStyle="display:none"
									cssClass="input-cmd" name="content.relationText" cols="103"
									rows="2"></ww:textarea></td>
							</tr>
		
						</table>
						</td>
					</tr>
					<!-- 映射 -->
					<tr id='tab5' helpid="application_module_form_info_mapping" style='display: none' valign="top">
						<ww:hidden id="mappingStr" name="content.mappingStr" />
		
						<td colspan="4" height="20">
						<table width="100%">
							<tr>
								<td>
								<fieldset style="HEIGHT: 50px"><legend>{*[Basic]*}</legend>
								<table class="id1" width="80%">
									<tr>
										<td class="commFont">{*[Database]*}{*[Table]*}{*[Name]*}:</td>
										<td class="commFont">{*[synchronouslyData]*}:</td>
									</tr>
									<tr>
										<td><ww:select cssClass="input-cmd" id="tableName"
											name="content.tableName"
											list="#fh.getDataBaseTableMap(#parameters.application)"
											theme="simple" onchange="addColOptions(true)" cssStyle="width:90%"/>
									</td>
									<td>
									    <input type="hidden" id="domainName" name="domainName"/>
									    <input type="hidden" id="mappingID" name="mappingID"/>
										<button onclick="synchronouslyData()"><img border=0 alt="{*[synchronouslyData]*}" src="<ww:url value='/resource/image/synchronouslyData.png'/>"/>{*[synchronouslyData]*}</button>
									</td>
									</tr>
								</table>
								</fieldset>
								</td>
							</tr>
		
							<tr>
								<td>
								<fieldset style="HEIGHT: 300px"><legend>{*[Configurations]*}</legend>
								<table style="width: 100%;" border="0">
									<tr><td align="right" colspan="3" style="height:50px">
										<input type="button" value="{*[Add]*}" onclick="addRows()" />
									</td></tr>
									<tr><td style="height:200px">
									<div style="overflow:auto;height:250px">
									<table style="width: 80%;">
										<tbody id="mappingtb">
											<tr>
												<td>{*[FieldName]*}</td>
												<td>{*[ColumnName]*}</td>
												<td>&nbsp;</td>
											</tr>
										</tbody>
									</table>
									</div>
									</td></tr>
								</table>
								</fieldset>
								</td>
							</tr>
						</table>
						</td>
					</tr>
					<tr id='tab6' helpid="application_module_form_info_advance" style='display: none' valign="top" height="100%">
					<ww:bean name="cn.myapps.core.dynaform.summary.action.SummaryCfgHelper" id="summaryCfgHelper"></ww:bean>
					<ww:hidden name='content.summaryCfg.id' />
					<ww:hidden name='content.summaryCfg.formId' />
					
					<ww:hidden name='content.summaryCfg.applicationid' />
						<td>
							<table  width="80%" border="0" cellpadding="0" cellspacing="0" width="100%" class="id1">
							  <tr>
							    <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="4">
							    	<tr>
							        <td><span class="commFont">{*[Title]*}:</span></td>
						          </tr>
							      <tr>
							        <td><ww:textfield cssClass="input-cmd" name='content.summaryCfg.title' /></td>
						          </tr>
							      <tr>
							        <td><span class="commFont">{*[Style]*}:</span></td>
						          </tr>
							      <tr>
							        <td><ww:select id="_style" name="content.summaryCfg.style"
														list="#summaryCfgHelper.getStyleList()" value="content.summaryCfg.style"
														cssClass="input-cmd" onchange="resplaceImg(this.value);"/></td>
						          </tr>
							      <tr>
							        <td><span class="commFont"><img alt="pending-head" id="image1"	src="" /></span></td>
						          </tr>
							      <tr>
							        <td><span class="commFont">{*[OrderBy]*}:</span></td>
						          </tr>
							      <tr>
							        <td><ww:select name="content.summaryCfg.orderby"
														list="#{'CREATED':'{*[CREATED]*}','LASTMODIFIED':'{*[LAST_MODIFIED]*}'}"
														cssClass="input-cmd" emptyOption="true" /></td>
						          </tr>
						        </table></td>
							    <td ><table width="100%" border="0" cellspacing="0" cellpadding="4">
							      <tr>
							        <td><span class="commFont">{*[Type]*}:</span></td>
						          </tr>
							      <tr>
							        <td><ww:radio name="content.summaryCfg.type"
									                            label="{*[Type]*}" list="#{'00':'{*[Design]*}','01':'{*[Script]*}'}"
									                            onclick="modeChange(this.value)" theme="simple" value="content.summaryCfg.type"/></td>
						          </tr>
							      <tr>
							        <td><div id="docSummaryCfg_type_00">
																			<ww:optiontransferselect id="fieldSelect"  
																				tooltip="Select fields to summary" name="fieldNames" theme="simple"
																				leftTitle="{*[All_Fields]*}" multiple="true" emptyOption="true"
																				rightTitle="{*[Show]*}{*[Fields]*}" list="{}" 
																				addToRightLabel="  >  "
																				addToLeftLabel="  <  "
																				doubleId="selectedList" 
																				doubleList="{}" doubleName="selectedFieldNames"
																				doubleCssStyle="height:10px;"
																			 />
																			 
																			 <ww:hidden name="content.summaryCfg.fieldNames"/>
																			</div>
																			
																			<div id="docSummaryCfg_type_01" style="display: none;">
																			<table>
																			<tr><td><button class="button-image" onclick="openIscriptEditor('content.summaryCfg.summaryScript','{*[Script]*}{*[Editor]*}','{*[SummaryScript]*}','content.name','{*[Save]*}{*[Success]*}');"><img alt="Open with IscriptEditor" src="<ww:url value='/resource/image/editor.png' />"/></button>
																			</td></tr>
																			<tr><td><ww:textarea cssClass="height:150px;width:200px;"
																					label="{*[Script]*}" name="content.summaryCfg.summaryScript" cols="45"
																					rows="20" theme="simple" />
																			</td></tr>
																			</table>
																				
																				
																			</div></td>
						          </tr>
						        </table></td>
						      </tr>
				</table>
					
						</td>
					</tr>
				</ww:form>
			</table>
			</td></tr>
		</table>
		</td>
	</tr>
</table>
</div>
</body>
</html>